-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Receipt logos: add support for black-and-white binary netpbm images. #282
Conversation
* Black-and-white PBM as only supported logo image format. * Logos stored in site config base64-encoded. * Some problems with vertical spacing of pixels are apparent. * Hacky triplication of horizontal pixels to achieve alignment during testing.
* Ignore comment lines during data extraction. * Use 'imagesize' library to retrieve width and height metadata.
You may find it easier to use the pillow library to load the image, convert it to black+white if necessary, and then access the raw data. It's already a dependency of quicktill (transitively via reportlab) so it's guaranteed to be available on till installations. |
Ach, I knew I should've checked more thorougly, or remembered that from dabbling with Would you prefer that approach, and if so, any thoughts on whether storing the logo in the DB makes sense, or is a filename reference OK? (it was finding the contents of a |
I think storing the data as a config option in the database makes perfect sense. A shame it has to be base64 encoded, but that's on me for not having a binary config type! Something to note for the future. |
No problem - yep, the base64 encoding is something of a tradeoff. I'll leave the config/storage as-is for now. |
Ok, that's progress, of a sort :) Is the black printed region near the left of your photo (outside of the circle) visible when viewing the input image? A mini todo-list of issues:
|
I think points 1 and 3 are to do with the print mode — you're using mode 0, for "8-dot single-density", which makes the printer double each pixel horizontally and triple it vertically. Mode 33, "24-dot double-density" should give more sensible results, but you'll need to work in groups of 24 rows instead of 8. My image does have black outside the circle — that must be the default background for |
…e ranges and up-to-8-bit column bitarrays.
Perhaps the stripes would disappear if we issue a single |
I don't think so — how would it know where the image stops? I expect we would get one valid row and then the remainder of the image data would be interpreted as text. |
Co-authored-by: Stephen Early <[email protected]>
I can't take the |
Ubuntu 22.04 has |
Partially reverts commit 6e086e7.
This may seem silly, but I'm going to rewrite that function from scratch. I haven't looked at the code for it (you'll have to take my word for that), but it's MIT-licensed whereas this is GPL -- it'd be fine to incorporate it with the appropriate inclusion of the license text, making it clear that it's vendored, etc, but I think it'll be simpler here for me to re-implement it (perhaps famous last words). |
That sounds sensible. You might want to implement something that always returns the requested number of items in the batch, padding if necessary, because it could make dealing with images that aren't a multiple of 24 pixels high a bit simpler. |
Ok, that's the batching/chunking code reimplemented, and seems to be working well here. The problem above was due to a missing |
Excellent, that looks much better. How much time does that take to print? |
It's quite slow. I need to spend some time this evening turning it up to see at what speed it breaks!
|
Sounds good. I also wonder whether an outlined version of the image might be preferable energy-wise (even if it doesn't affect the output speed). FWIW: On a separate branch, I've pushed a commit https://github.com/jayaddison/quicktill/commit/af596773b44973b5d10e17829ea1890e8ed666d6 that migrates from |
After I accept the pull request I'm tempted to rework it to use Pillow to read the image and drop the imagesize dependency.
We should then be able to include images in pdf output too, fairly easily.
Finally, I went to add an "image" config type and add support to the web interface for uploading and displaying images in the config.
|
Followup: I just pushed a commit that removes the This allows the image to be anything understood by the Pillow library. For example, here's what it prints when I use a huge transparent PNG from https://www.miltonbrewery.co.uk/media/pumpclips/minotaur.png : |
Brilliant! Nice to have learned some ESC/P along the way here. Cheers :) |
Status
Screenshots
Related
Resolves #156.